package com.leyou.item.controller;

import com.leyou.item.pojo.dto.SpecParamDTO;
import com.leyou.item.service.SpecParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//spec/params?gid=15
@RestController
@RequestMapping("/spec")
public class SpecParamController {
    @Autowired
    private SpecParamService specParamService;

    /*根据参数数组id 查询参数列表*/
    @GetMapping("/params")
    public ResponseEntity<List<SpecParamDTO>> querySpecParams(
            @RequestParam(value = "gid",required = false)Long pid,
            @RequestParam(value = "cid",required = false)Long cid,
            @RequestParam(value = "searching",required = false)Boolean searching   //是否可用于搜索
    ){
        return ResponseEntity.ok().body(specParamService.querySpecParamsByGroupId(pid,cid,searching));
    }

}
